local skel = fk.CreateSkill {
  name = "rmt__weiming",
  tags = {Skill.Compulsory},
}

Fk:loadTranslationTable{
  ["rmt__weiming"] = "威命",
  -- 当你获得手牌后，若为为手牌数最多
  [":rmt__weiming"] = "锁定技，当你的手牌数成为全场最多时，若此时为你的回合内/外，你获得〖耀武〗/〖骄恣〗至你发动之；"..
  "若你已有对应技能，则改为回复1点体力。",

  ["$rmt__weiming1"] = "朝廷官爵威福，今操在谁手？",
  ["$rmt__weiming2"] = "汉皇承天威命，某家携之，亦可用！",
}

skel:addEffect(fk.AfterCardsMove, {
  anim_type = "negative",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(skel.name) then
      for _, move in ipairs(data) do
        if move.to == player and move.toArea == Player.Hand then
          return table.every(player.room.alive_players, function (p)
            return player:getHandcardNum() >= p:getHandcardNum()
          end)
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local turn_event = room.logic:getCurrentEvent():findParent(GameEvent.Turn)
    local skill = "rmt__yaowu"
    if turn_event == nil or turn_event.data.who ~= player then
      skill = "rmt__jiaozi"
    end
    if not player:hasSkill(skill, true) then
      room:setPlayerMark(player, "rmt__weiming_"..skill, 1)
      room:handleAddLoseSkills(player, skill, nil, true, false)
    elseif player:getMark("rmt__weiming_"..skill) > 0 and player:isWounded() then
      room:recover({
        who = player,
        num = 1,
        recoverBy = player,
        skillName = skel.name,
      })
    end
  end,
})

skel:addEffect(fk.SkillEffect, {
  can_refresh = function (self, event, target, player, data)
    return target == player and player:getMark("rmt__weiming_"..data.skill.name) > 0
  end,
  on_refresh = function (self, event, target, player, data)
    local room = player.room
    room:setPlayerMark(player, "rmt__weiming_"..data.skill.name, 0)
    room:handleAddLoseSkills(player, "-"..data.skill.name, nil, true, false)
  end,
})


return skel
